package biopepa;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

//import parserBiopepa.*;

public class Automaton {
		private String autoName;
		private  HashMap<String , Integer> autoVariables; //variabile + valore iniziale
		public  HashMap<String,NewParameter> autoParameters;
		public  HashMap<String,NewParameter> autoExpressions;
//		public  ArrayList<String> autoExpressions;
		public HashMap<String , DiscreteTrans> autoDiscreteTrans;
		public boolean isContinuous;

//		public Automaton(NewSpecies species){
//			autoName = species.speciesName;
//			autoVariables = new HashMap<String,Integer>();
//			autoParameters = new HashMap<String,NewParameter>();
//			autoExpressions = new HashMap<String,NewParameter>();
//			autoExpressions = new ArrayList<String>();
//			autoDiscreteTrans = new HashMap<String , DiscreteTrans>();
//			isContinuous = false;

//			autoVariables.put(species.speciesName , species.speciesInitial);
			
//			Iterator iterator1 = species.getActionsEnabledObjects().keySet().iterator();  
//			while (iterator1.hasNext()) {  
//			   String key = iterator1.next().toString();  
//			   DiscreteTrans newDiscreteTrans;
//			   newDiscreteTrans = new DiscreteTrans(species , species.getActionsEnabledObjects().get(key));
//			   autoDiscreteTrans.put(newDiscreteTrans.discreteName , newDiscreteTrans);
//			}
		    
//		}
	
		
		public Automaton(NewSpecies species , LocationAndInitial locationAndInitial , BiopepaModel model){
//			autoName = species.speciesName + "." + locationAndInitial.location.locationName;
			autoName = species.speciesName ;
			autoVariables = new HashMap<String,Integer>();
			autoParameters = new HashMap<String,NewParameter>();
			autoExpressions = new HashMap<String,NewParameter>();
//			autoExpressions = new ArrayList<String>();
			autoDiscreteTrans = new HashMap<String , DiscreteTrans>();
			
			isContinuous = species.isContinuous;

//			autoVariables.put(species.speciesName + "." + locationAndInitial.location.locationName , locationAndInitial.initial);
			autoVariables.put(species.speciesName , locationAndInitial.initial);
			//System.out.println("qua: " + this.getVariables().get(species.speciesName + "@" + locationAndInitial.location.locationName));
			//System.out.println("qua: " + species.speciesInitial);
			
			Iterator iterator1 = species.getActionsEnabledObjects().keySet().iterator();  
			while (iterator1.hasNext()) {  
			   String key = iterator1.next().toString();  
			   DiscreteTrans newDiscreteTrans;			   
			   newDiscreteTrans = new DiscreteTrans(this , locationAndInitial.location , species , species.getActionsEnabledObjects().get(key) , model);		   
			   autoDiscreteTrans.put(newDiscreteTrans.discreteNameWith , newDiscreteTrans);
			   //System.out.println("per: " + newDiscreteTrans.discreteName + " guard: " + newDiscreteTrans.guard);
			   
			}
		    
		}
		
		
		public Automaton(String name){
			autoName = name;
			autoVariables = new HashMap<String,Integer>();
			autoParameters = new HashMap<String,NewParameter>();
			autoExpressions = new HashMap<String,NewParameter>();
//			autoExpressions = new ArrayList<String>();
			autoDiscreteTrans = new HashMap<String , DiscreteTrans>();
			isContinuous = false;
		}
		
		public  String getAutoName(){
			return autoName;
			
		}
		
		public HashMap<String , Integer> getVariables(){
			return this.autoVariables;
		}
		
		public HashMap<String , DiscreteTrans> getAutoDiscreteTrans(){
			return this.autoDiscreteTrans;
		}

		
		

}

